package com.yaoxiaoqing.objectclass;

import java.util.Random;

public class CreateCode {
    public static void main(String[] args) {
        System.out.println(createCode(5));
    }
    public  static String createCode(int num){
        String code = "";
        for (int i = 0; i < num; i++) {
            //随机0 （整数0-9），1（A-Z），2（a-z）
            Random r = new Random();
            int type = r.nextInt(3);
            switch (type) {
                case 0:
                    code += r.nextInt(10);
                    break;
                case 1:
                    code += (char) (r.nextInt(26) + 65);
                    break;
                case 2:
                    code += (char) (r.nextInt(26) + 97);
                    break;
            }
        }

        return code;
    }
}
